class Dog:
    # 模拟小狗蹲下（sit())和打滚(roll_over)的能力

    # __init__方法可以视为初始化方法，每次运行python程序时会自动运行它
    # 类中的每个属性都必须有初始值,初始值可以在__init__方法中指定
    def __init__(self,name:str,age:int):
        # 初始化name和age
        self.name = name
        self.age = age

    # 通过类内部的方法修改属性值
    def update_age(self,year):
        self.age+=year

    def sit(self):
        print(self.name.title() + " is now sitting.")

    def roll_over(self):
        print(self.name.title() + " is now rolling over.")

#  根据类来创建实例
my_dog = Dog('Wang Peixu',19)
print("My dog's name is "+ my_dog.name.title() + ".")
print("My dog is "+ str(my_dog.age) + " years old.")
my_dog.sit()
my_dog.roll_over()
